package org.sy.lab.多线程基础._3_同步辅助类._1_Semaphore信号量;

import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;

public class Queue {
	
	private Semaphore semaphore = new Semaphore(3);
	
	public void print(String name) {
		
		try {
			semaphore.acquire();
			System.out.println(name + "开始打印");
			TimeUnit.SECONDS.sleep(1);
			System.out.println("--" + name + "打印结束");
		} catch (InterruptedException e) {
			e.printStackTrace();
		} finally {
			semaphore.release();
		}
	}
}
